﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using final_darskade.Models;

namespace final_darskade.Controllers
{
    public class ProfController : Controller
    {
        //
        // GET: /Prof/

        public ActionResult Index()
        {
            string username = (string)Session["UserName"];
            if (username == null) Redirect("/");
            user user = (from row in Helper.database.users
                        where row.username == username
                        select row).First();
            var query = from klass in Helper.database.klasses
                        where klass.prof_id == user.user_id
                        select klass;
            return View("ProfPage", query.ToList());
        }

        [HttpGet]
        public ActionResult StudentList(int? klassid)
        {
            if (klassid == null) return Redirect("/");
            else
            {
                var query = from student in Helper.database.klass_members
                            where student.klass_id == klassid
                            select student;
                return View(query.ToList());
            }
        }

    }
}
